package com.infocollect.project.wx.controller;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

//import com.infocollect.project.common.sms.MessageSenderUtil;
import com.infocollect.common.sms.MessageSenderUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.infocollect.common.constant.Constants;
import com.infocollect.common.utils.StringUtils;
import com.infocollect.framework.redis.RedisCache;
import com.infocollect.framework.web.controller.BaseController;
import com.infocollect.framework.web.domain.AjaxResult;
import com.infocollect.framework.web.page.TableDataInfo;
import com.infocollect.project.wx.interceptor.WXPermission;
import com.infocollect.project.wx.utils.WxUserUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import me.chanjar.weixin.mp.api.WxMpService;

/**
 * @author Edward
 */
@Api("微信公众号")
@AllArgsConstructor
@RestController
@RequestMapping("/wx/h5")
public class WxH5Controller extends BaseController{
    private final WxMpService wxService;

    @Autowired
    private RedisCache redisCache;

    private static final String PHONE_CODE = "PHONE_CODE";

    @ApiOperation(value = "单点成功获取openid-测试")
    @GetMapping("/openid/test")
    public AjaxResult getOpenIdTest(ModelMap map) {
    	String userName = "oUOj153xsaLRFkE62klXrkGsbFRk";
    	WxUserUtil.login(userName);
        return new AjaxResult().success("success", userName);
    }

    @ApiOperation(value = "单点成功获取openid")
    @GetMapping("/openid")
    @WXPermission
    public AjaxResult getOpenId(ModelMap map) {
    	String userName = WxUserUtil.getUser();
        return new AjaxResult().success("success", userName);
    }

}
